package com.example.lirisheng.springbootfinalexperiment.security;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.Collections;

public class WeiAuthenticationToken extends AbstractAuthenticationToken {

    private String open_id;
    private Object principal;
    private HttpServletRequest request;

    public WeiAuthenticationToken(String open_id,HttpServletRequest request){
        super(Collections.emptyList());
        this.open_id=open_id;
        this.request=request;
    }

    public WeiAuthenticationToken(Object principal, Collection<? extends GrantedAuthority> authorities){
        super(authorities);
        this.principal=principal;
        setAuthenticated(true);

    }


    public String getOpen_id() {
        return open_id;
    }

    public HttpServletRequest getRequest() {
        return request;
    }

    @Override
    public Object getPrincipal() {
        return principal;
    }

    @Override
    public Object getCredentials() {
        return "";
    }
}
